package org.jsea.meta.api.bean;

import lombok.Getter;
import lombok.Setter;
import org.jsea.meta.api.constant.ActionType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 表不维护序列信息.
 * 有些序列是通过雪花算法或者redis生成。
 * *
 * author   Jiang.hy
 * create   2022-04-09
 */
@Getter
@Setter
public class ApiTableInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    /*
    不考虑在开发阶段就能暴漏的错误配置
    资源，允许是sql表达式
     */
    private String source;
    private String primaryKey;//主键名称
    //大部分资源只有查询权限，允许多次扩容
    private List<ActionType> action = new ArrayList<>(1);
    private List<Class<? extends MetaApiInterceptor>> apply;
    private Map<String, Object> props;

    public ApiTableInfo() {
    }

    public ApiTableInfo(String source) {
        this.source = source;
    }

    @Override
    public String toString() {
        return source;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ApiTableInfo info = (ApiTableInfo) o;
        return Objects.equals(source, info.source);
    }

    @Override
    public int hashCode() {
        return Objects.hash(source);
    }
}
